function GetUrlParam(paraName) {
    // var url = document.location.toString();
    var url = 'http://www.nowcoder.com?key=1&key=2&key=3&test=4'
    var arrObj = url.split("?");
    if (arrObj.length > 1) {
        var arrPara = arrObj[1].split("&");
        var arr;
        for (var i = 0; i < arrPara.length; i++) {
            arr = arrPara[i].split("=");
            if (arr != null && arr[0] == paraName) {
                return arr[1];
            }
        }
        return "";
    }
    else {
        return "";
    }
}

function GetUrlParam1() {
    // var url = document.location.toString();
    var url = 'http://www.nowcoder.com?key=1&key=2&key=3&test=4'
    var arrObj = url.split("?");
    if (arrObj.length > 1) {
        var arrPara = arrObj[1].split("&");
        var res = {};
        for (var i = 0; i < arrPara.length; i++) {
            let currArrPara = arrPara[i].split("=");
            let key = currArrPara[0];
            let value = currArrPara[1]
            res[key] = value;
        }
        return res;
    }
    else {
        return {};
    }
}

// let res = GetUrlParam1('test');
// console.log(res);

var url = "https://sample.com/?a=1&e&b=2&c=3#hash";
function GetUrlParam2() {
    // var url = document.location.toString();
    var arrObj = url.split("?");
    if (arrObj.length > 1) {
        var arrPara = arrObj[1].split("&");
        var res = {};
        for (var i = 0; i < arrPara.length; i++) {
            let currArrPara = arrPara[i].split("=");
            let key = currArrPara[0];
            let value = currArrPara[1]
            if (currArrPara.length > 1) {
                res[key] = value;
            } else {
                res[key] = '';
            }

        }
        return res;
    }
    else {
        return {};
    }
}

let res = GetUrlParam2(url);
console.log(res);